package com.lh.service.impl;

import com.lh.domain.Category;
import com.lh.mapper.CategoryMapper;
import com.lh.service.CategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 手游类别 服务实现类
 * </p>
 *
 * @author lh
 * @since 2023-10-24
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * @param id
     * @return
     * 先取出categoryCode,通过splist("-"),才分成字符数组,按照长度可以分为2A,3B,4C
     * 要想关联一，二，三级菜单,他们除了最后一个,前面都是相同的.但是一级菜单是本身不一样
     * -------这是下拉框获取--------
     */
    public List<Category> getList(int id){

        //通过id获取当前级别的编码
        Category category = categoryMapper.selectById(id);
        String nameOne = category.getCategoryCode();
        //通过模糊查询获取当前级别的下一个级别
        List<Category> list = categoryMapper.selectAllByCategoryCode(nameOne);
        return list;
    }

    @Override
    public List<Category> getListOne() {
        return categoryMapper.selectByCategoryCodeOne();
    }

}
